package com.jyniubi.oss.controller;

import com.jyniubi.base.result.R;
import com.jyniubi.oss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@Api(tags = "存储服务")

@RequestMapping("/admin/oss")
public class OssController {
    @Resource
    private OssService ossService;
    @ApiOperation("上传文件返回文件路径")
    @PostMapping("/upload")
    public R upload(MultipartFile file, @RequestParam("module")String module){
        String path = ossService.upload(file,module);
        return R.ok().data("path",path);
    }
    @ApiOperation("删除文件")
    @DeleteMapping("/delete")
    public R delete(@RequestParam("path") String path){
        ossService.delete(path);
        return R.ok();
    }
}
